﻿$(document).ready(main);

function main() {
    setInterval(function () {
        //alert("1/2 min");
        //updateMailbox1();
        updateMailbox2();
        //updateMailbox3();
        updateMailbox4();

    }, 30000);
}

function updateMailbox1() {

}

function updateMailbox2() {
    var escritor = "";
    $("#myBody tr").remove();
    //$("#div_assign_1 table")
    $.ajax({
        url: "\UpdateMailbox2",
        type: "post",
        data: {},
        dataType: "json",
        success: function (data) {
            //$("#lblMessage").text(data.result);
            console.log(data);
            //escritor += "<table class='table-bordered table-striped table-condensed flip-content' id='assign_1'>" +
            //                "<thead class='flip-content'>" +
            //                    "<tr>" +
            //                        "<th>#</th>" +
            //                        "<th>NUMERO SOLICITUD</th>" +
            //                        "<th>EMPRESA</th>" +
            //                        "<th>GRUPO</th>" +
            //                        "<th class='hidden-480'>FECHA REGISTRO</th>" +
            //                    "</tr>" +
            //                "</thead>" +
            //                "<tbody>";
                            $.each(data, function (i, item) {
                    escritor += "<tr>" +
                                    '<td>' + parseInt(i+1) + '</td>' +
                                    '<td><a class="link-modal-asign-credit-request" data-toggle="modal" href="#responsive">' + item.requestId + '</a></td>' +
                                    '<td>' + item.socialReason + '</td>' +
                                    '<td>' + item.group + '</td>' +
                                    '<td class="hidden-480">' + item.recordDate + '</td>' +
                                "</tr>";
                            });
                        escritor += '</tbody>'+
                        '</table>';
                        $("#myBody").append(escritor);
        }

    });
}

function updateMailbox3() {

}

function updateMailbox4() {

}